﻿<AddDataFormTemplateSpec 
	xmlns="bb_appfx_adddataformtemplate"
	xmlns:common="bb_appfx_commontypes" 
	ID="a315b374-1884-40f7-a515-4ac277a6e11c" 
	Name="Designation Custom Add Data Form"
	Description="Add Designation Record" 
	Author="Blackbaud Profesional Services"
	DataFormInstanceID="cc186865-8aad-4394-bb00-c32e0d22e63f" 
	RecordType="Designation"
	common:SecurityUIFolder="Service Bus Adapter"
	>

	<SPDataForm>
		<!-- describe the save SP -->
		<SaveImplementation SPName="USP_DATAFORMTEMPLATE_ADD_DESIGNATION_CUSTOM">
			<common:CreateProcedureSQL>
				<![CDATA[
create procedure dbo.USP_DATAFORMTEMPLATE_ADD_DESIGNATION_CUSTOM
(
  @ID uniqueidentifier = null output,
  --@CONTEXTID uniqueidentifier,
  @CHANGEAGENTID uniqueidentifier = null,
  @DESIGNATIONLEVEL1ID uniqueidentifier = null,
  @DESIGNATIONLEVEL2ID uniqueidentifier = null,
  @DESIGNATIONLEVEL3ID uniqueidentifier = null,
  @DESIGNATIONLEVEL4ID uniqueidentifier = null,
  @DESIGNATIONLEVEL5ID uniqueidentifier = null,
  @DESIGNATIONREPORT1CODEID uniqueidentifier = null,
  @DESIGNATIONREPORT2CODEID uniqueidentifier = null,
  @GLDEPARTMENTID uniqueidentifier = null,
  @PROJECTCODE nvarchar(100) = '',
  @ISACTIVE bit = 1,
  @USERID nvarchar(512) = '',
  @VANITYNAME nvarchar(512) = '',
  @ACCOUNTNUMBER nvarchar(100) = '',
  @VSECATEGORYID uniqueidentifier = null,
  @STARTDATE datetime = null,
  @ENDDATE datetime = null,
  @DESIGNATIONUSECODEID uniqueidentifier = null,
  @VSESUBCATEGORYID uniqueidentifier = null,
  @DESIGNATIONLEVELTYPEHIERARCHYITEMID uniqueidentifier = null,
  @ISREVENUEDESIGNATION bit = 0,
  @BASECURRENCYID uniqueidentifier = null 
)
as

set nocount on;

if @ID is null
    set @ID = newid()


if @CHANGEAGENTID is null  
    exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output

declare @CURRENTDATE datetime
set @CURRENTDATE = getdate()

begin try
	-- handle inserting the data
	insert into dbo.DESIGNATION
		(
      ID,
      DESIGNATIONLEVEL1ID,
      DESIGNATIONLEVEL2ID,
      DESIGNATIONLEVEL3ID,
      DESIGNATIONLEVEL4ID,
      DESIGNATIONLEVEL5ID,
      DESIGNATIONREPORT1CODEID,
      DESIGNATIONREPORT2CODEID,
      GLDEPARTMENTID,
      PROJECTCODE,
      ISACTIVE,
      USERID,
      VANITYNAME,
      ACCOUNTNUMBER,
      VSECATEGORYID,
      STARTDATE,
      ENDDATE,
      DESIGNATIONUSECODEID,
      VSESUBCATEGORYID,
      DESIGNATIONLEVELTYPEHIERARCHYITEMID,
      ISREVENUEDESIGNATION,
      BASECURRENCYID,
      ADDEDBYID, CHANGEDBYID, DATEADDED, DATECHANGED
    )
    values(
      @ID,
      @DESIGNATIONLEVEL1ID,
      @DESIGNATIONLEVEL2ID,
      @DESIGNATIONLEVEL3ID,
      @DESIGNATIONLEVEL4ID,
      @DESIGNATIONLEVEL5ID,
      @DESIGNATIONREPORT1CODEID,
      @DESIGNATIONREPORT2CODEID,
      @GLDEPARTMENTID,
      @PROJECTCODE,
      @ISACTIVE,
      @USERID,
      @VANITYNAME,
      @ACCOUNTNUMBER,
      @VSECATEGORYID,
      @STARTDATE,
      @ENDDATE,
      @DESIGNATIONUSECODEID,
      @VSESUBCATEGORYID,
      @DESIGNATIONLEVELTYPEHIERARCHYITEMID,
      @ISREVENUEDESIGNATION,
      @BASECURRENCYID,
      @CHANGEAGENTID, @CHANGEAGENTID, @CURRENTDATE, @CURRENTDATE
  )
	
end try

begin catch
    exec dbo.USP_RAISE_ERROR
    return 1
end catch

return 0				
				]]>
			</common:CreateProcedureSQL>
		</SaveImplementation>
	</SPDataForm>


	<!-- describe fields on the form, which correspond to parameters on the SP.  Note that system parameters 
	like the context @ID, @CONTEXTID, and @CURRENTAPPUSERID need not be listed. -->
	<common:FormMetaData FixedDialog="true">
		<common:FormFields>

      <!--<common:FormField FieldID="ID"                                  Caption="ID"                                  DataType="Guid" />-->
			<common:FormField FieldID="DESIGNATIONLEVEL1ID"                 Caption="DESIGNATIONLEVEL1ID"                 DataType="Guid" />
      <common:FormField FieldID="DESIGNATIONLEVEL2ID"                 Caption="DESIGNATIONLEVEL2ID"                 DataType="Guid" />
      <common:FormField FieldID="DESIGNATIONLEVEL3ID"                 Caption="DESIGNATIONLEVEL3ID"                 DataType="Guid" />
      <common:FormField FieldID="DESIGNATIONLEVEL4ID"                 Caption="DESIGNATIONLEVEL4ID"                 DataType="Guid" />
      <common:FormField FieldID="DESIGNATIONLEVEL5ID"                 Caption="DESIGNATIONLEVEL5ID"                 DataType="Guid" />
      <common:FormField FieldID="DESIGNATIONREPORT1CODEID"            Caption="DESIGNATIONREPORT1CODEID"            DataType="Guid" />
			<common:FormField FieldID="DESIGNATIONREPORT2CODEID"            Caption="DESIGNATIONREPORT2CODEID"            DataType="Guid" />
      <common:FormField FieldID="GLDEPARTMENTID"                      Caption="GLDEPARTMENTID"                      DataType="Guid" />
      <common:FormField FieldID="PROJECTCODE"                         Caption="PROJECTCODE"                         DataType="String" MaxLength="100" />
      <common:FormField FieldID="ISACTIVE"                            Caption="ISACTIVE"                            DataType="Boolean" />
      <common:FormField FieldID="USERID"                              Caption="USERID"                              DataType="String" MaxLength="512" />
      <common:FormField FieldID="VANITYNAME"                          Caption="VANITYNAME"                          DataType="String" MaxLength="512" />
      <common:FormField FieldID="ACCOUNTNUMBER"                       Caption="ACCOUNTNUMBER"                       DataType="String" MaxLength="100" />
      <common:FormField FieldID="VSECATEGORYID"                       Caption="VSECATEGORYID"                       DataType="Guid" />
      <common:FormField FieldID="STARTDATE"                           Caption="STARTDATE"                           DataType="Date" />
      <common:FormField FieldID="ENDDATE"                             Caption="ENDDATE"                             DataType="Date" />
      <common:FormField FieldID="DESIGNATIONUSECODEID"                Caption="DESIGNATIONUSECODEID"                DataType="Guid" />
      <common:FormField FieldID="VSESUBCATEGORYID"                    Caption="VSESUBCATEGORYID"                    DataType="Guid" />
      <common:FormField FieldID="DESIGNATIONLEVELTYPEHIERARCHYITEMID" Caption="DESIGNATIONLEVELTYPEHIERARCHYITEMID" DataType="Guid" />
      <common:FormField FieldID="ISREVENUEDESIGNATION"                Caption="ISREVENUEDESIGNATION"                DataType="Boolean" />      
      <common:FormField FieldID="BASECURRENCYID"                      Caption="BASECURRENCYID"                      DataType="Guid" />      


    </common:FormFields>
	</common:FormMetaData>

</AddDataFormTemplateSpec>